// Mass noble packet
javascript:
var coins=7;
function selectAllMax2(form,textMax,textNothing)
{
  for(var i=0;i<form.length;i++) {
    var select=form.elements[i];
    if(select.selectedIndex!=null) {
      if(max){
        if(select.length>(coins+1)){
          select.selectedIndex=select.length-(coins+2);
        } else
          select.value=0;
      }else
        select.value=0;
    }
  }
  max=max?0:1;
  anchor=document.getElementById('select_anchor_top');
  anchor.firstChild.nodeValue=max?textMax:textNothing;
  anchor=document.getElementById('select_anchor_bottom');
  anchor.firstChild.nodeValue=max?textMax:textNothing;
  changeBunches(form);
}
if(document.URL.match('screen=snob')&&document.URL.match('mode=reserve')){
  selectAllMax2(document.forms['villages'],'Choose maximum amount','Select nothing');
} else {
  alert('Script only works on academy store page');
}


// Mass nobe packet by hectoct
javascript:
var coins=7;
function selectAllMax_hectoct(form,textMax,textNothing)
{
  var tables = document.getElementsByTagName('table')
  var t = tables[tables.length-1];
  var str_rows="";
  str_rows = "Num tables = " + tables.length + "Rows = [" + t.rows.length + "]";
  alert(str_rows);
  for(var i=0; i<t.rows.length;i++) {
    var row = t.rows[i];
    if (row.cells.length==4) {
      var cell = row.cells[0]; /* alert(i+cell.innerHTML); */
      var village = cell.firstChild.firstChild;
      var village_name;
      if(village!=null) {
        village_name = village.nodeValue; /* alert(i+village_name); */
        var c = village_name.charAt(0);
        if(c=='x' || c=='!') { village_name=null; }
      } else { village_name=null; }
      /* alert(i+village_name); */
      
      var select = row.cells[3].getElementsByTagName('select'); /* alert("Num select = " + select.length); */
      if (select.length==1) { select = select[0];}
      else { select = null; }
  
      if (select!=null && select.selectedIndex!=null) {
        /* alert(i+"Option obj"); */
        if(max && village_name!=null) {
          if(select.length>(coins+1)) {
            select.selectedIndex=select.length-(coins+2);
          } else {
            select.value=0;
          }
        } else {
          select.value=0;
        }
      }
    }
  }
  max=max?0:1;
  anchor=document.getElementById('select_anchor_top');
  anchor.firstChild.nodeValue=max?textMax:textNothing;
  anchor=document.getElementById('select_anchor_bottom');
  anchor.firstChild.nodeValue=max?textMax:textNothing;
  changeBunches(form);
}

if(document.URL.match('screen=snob')&&document.URL.match('mode=reserve')){
  selectAllMax_hectoct(document.forms['villages'],'Choose maximum amount','Select nothing');
  alert(document.forms['villages'].length);
} else {
  alert('Script only works on academy store page');
}



// Mass Village Rename
javascript:
var text='I%20<3%20Servy';
var doc=document;
if(window.frames.length>0)
  doc=window.main.document;
var inputs=doc.getElementsByTagName('input');
for(i=0;i<inputs.length;i++){
  if(inputs[i].id.indexOf('edit_input')!=-1){
    inputs[i].value=text;
    inputs[i+1].click();
  }
}

end();
